"""
URL configuration for blogs project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, re_path
from django.views.static import serve

from appdemo.views import *
from blogs import settings

urlpatterns = [
    path('admin/', admin.site.urls),
    path('home/', home, name='home'),
    path('register/', register, name='register'),
    path('get_code/', get_code),
    path('login/', login, name='login'),
    path('logout/', logout, name='logout'),
    path('order/', order, name='order'),
    path('set_password/', set_password, name='set_password'),
    # media地址
    re_path('media/(?P<path>.*)', serve, {'document_root': settings.MEDIA_ROOT}),
    # 个人站点侧边筛选
    re_path('(?P<username>\w+)/(?P<condition>category|tag|archive)/(?P<param>.*)', site),
    # 测试左侧筛选菜单
    path('test_menu/', test_menu),
    # 文章详情页
    re_path('(?P<username>\w+)/article/(?P<article_id>\d+)', article_detail),
    # 文章点赞或者踩赞
    path('up_or_down/', up_or_down),
    # 评论
    path('comment/', comment),
    #     修改当前用户的头像
    path('set_avatar/', set_avatar),
    # 个人站点的路由，注意，该路由要写到最后一个路由配置
    re_path('(?P<username>\w+)', site),
]
